home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / spiele / publicdomain / liftrunner / source / liftrunner.amos / liftrunner.amosSourceCode < prev    next >
AMOS Source Code  |  1996-01-01  |  10KB  |  307 lines

  1. Rem ********************************************************** 
  2. Rem *                Lift Runner V1.0 Revision 7             * 
  3. Rem *           Created By Nigel Fredericks 25-7-1991        *   
  4. Rem *                   Using AMOS The Creator               * 
  5. Rem ********************************************************** 
  6. Rem
  7. Dim LEVELINFO(9,16)
  8. Global LEVELINFO(),LEVEL,B$,ENERGY,PLATFORM,TIME,HILEVEL,HITIME,EX
  9. Mvolume 20
  10. Music 1
  11. Wait Vbl 
  12. Set Rainbow 0,1,64,"(2,6,8)","(2,2,8)","(2,1,8)"
  13. Rainbow 0,56,40,255
  14. Screen Open 0,320,256,16,Lowres : Rem No need for the compiler to open the default screen
  15. Screen Open 1,320,256,16,Lowres
  16. Screen Open 2,320,256,16,Lowres
  17. Double Buffer 
  18. Autoback 0
  19. REAINFO
  20. Hide 
  21. Procedure REAINFO
  22.    Rem This procedure reads in lift and block positions 
  23.    For J=0 To 9
  24.       For I=0 To 16
  25.          Read LEVELINFO(J,I)
  26.       Next I
  27.    Next J
  28.    Data 32,48,128,192,208,0,64,96,160,224,256,288,-1,144,-1,-1,-1
  29.    Data 128,144,160,192,224,0,32,64,96,256,288,-1,176,208,240,-1,-1
  30.    Data 128,160,192,224,256,0,32,64,96,288,-1,-1,144,176,208,240,272
  31.    Data 48,80,96,256,272,0,128,160,192,224,288,-1,32,64,112,-1,-1
  32.    Data 32,48,64,80,96,0,128,160,192,224,256,288,112,-1,-1,-1,-1
  33.    Data 32,48,160,256,272,0,64,96,128,192,224,288,176,-1,-1,-1,-1
  34.    Data 48,128,144,160,208,0,64,96,224,256,288,-1,32,176,192,-1,-1
  35.    Data 64,208,224,256,272,0,32,96,128,160,288,-1,80,192,240,-1,-1
  36.    Data 48,128,144,192,288,0,64,96,224,256,-1,-1,32,160,176,208,304
  37.    Data 16,32,48,272,288,64,96,128,160,192,224,-1,0,256,304,-1,-1
  38. End Proc
  39. Procedure MAKESCREEN[LEVEL]
  40.    Rem Locates and places lifts and blocks
  41.    For I=0 To 4 : Rem Postions 0 To 4 in the data structure contain lift X co-ords 
  42.       SPEED=((Rnd(10)+1)*(Rnd(10)+1))+30 : Rem This is the speed the lift moves 
  43.       A$=" Start: M 0,148,"+Str$(SPEED)+" ; Move 0,-148,"+Str$(SPEED)+" ; Jump Start "
  44.       Bob I,LEVELINFO(LEVEL,I),10,1
  45.       Paste Bob LEVELINFO(LEVEL,I),0,10 : Rem Places top cable holder
  46.       Paste Bob LEVELINFO(LEVEL,I),190,11 : Rem Places lower cable holder  
  47.       For K=10 To 180 Step 10 : Rem Places lift cables 
  48.          Paste Icon LEVELINFO(LEVEL,I),K,3
  49.       Next K
  50.       Channel I To Bob I
  51.       Amal I,A$
  52.    Next I
  53.    For I=5 To 11 : Rem Places large blocks (Data position 5 to 11)
  54.       For J=0 To 4
  55.          If LEVELINFO(LEVEL,I)<>-1
  56.             Paste Icon LEVELINFO(LEVEL,I),J*45,1
  57.          End If 
  58.       Next J
  59.    Next I
  60.    For I=12 To 16 : Rem Places small blocks (Data postion 12 to 16)
  61.       For J=0 To 4
  62.          If LEVELINFO(LEVEL,I)<>-1
  63.             Paste Icon LEVELINFO(LEVEL,I),J*45,2
  64.          End If 
  65.       Next J
  66.    Next I
  67.    Make Icon Mask 
  68.    For I=0 To 30 Step 10 : Rem Place ladders at each end
  69.       Paste Icon 0,I,4
  70.       Paste Icon 0,I+90,4
  71.       Paste Icon 304,I+45,4
  72.       Paste Icon 304,I+135,4
  73.    Next I
  74.    Paste Icon 0,35,4 : Rem Patch up end of ladders
  75.    Paste Icon 0,125,4
  76.    Paste Icon 304,80,4
  77.    Paste Icon 304,170,4
  78. End Proc
  79. Procedure LEVELDRAW
  80.    Rem End of level procedure 
  81.    LEVEL=LEVEL+1
  82.    PLATFORM=0
  83.    Amal Off 
  84.    Bob Off 
  85.    Screen To Front 1
  86.    Screen 1
  87.    Curs Off 
  88.    Cls 0
  89.    If LEVEL>0
  90.       Pen 1 : Paper 0
  91.       Locate 6,3 : Print "To complete level";LEVEL;" you took"
  92.       Locate 13,5 : Print Timer/50;" seconds."
  93.       TIME=TIME+Timer/50
  94.       Locate 6,7 : Print "Total time taken so far:";TIME
  95.    End If 
  96.    Locate 13,13
  97.    Pen 1 : Paper 0
  98.    Print "Please Wait..."
  99.    If LEVEL<10
  100.       Locate 9,15
  101.       Print "Level";LEVEL+1;" being created!"
  102.    End If 
  103.    If LEVEL=10
  104.       Locate 3,17
  105.       Print "Congratulations You have completed"
  106.       Locate 14,18 : Print "LIFTRUNNER"
  107.       EX=-1
  108.    End If 
  109.    Locate 5,21 : Print "Press Fire Button To Continue"
  110.    Wait Vbl 
  111.    View 
  112.    Repeat 
  113.    Until Fire(1)
  114.    If EX Then Pop Proc
  115.    Bob Off : Amal Off 
  116.    Screen Close 0
  117.    Screen Open 0,320,256,16,Lowres
  118.    Screen Hide 0
  119.    Double Buffer 
  120.    Autoback 0
  121.    Rem Update Off 
  122.    Flash Off : Curs Off 
  123.    Get Sprite Palette 
  124.    Cls 0
  125.    Pen 1 : Paper 0
  126.    Locate 0,25 : Print "Energy Level :";ENERGY;"  "
  127.    Locate 21,25 : Print "Speedup Level :";Amreg(4)
  128.    Locate 5,27 : Print "Lift Runner V1.00    Level :";LEVEL+1
  129.    Def Scroll 1,2,215 To 320,225,-2,0
  130.    MAKESCREEN[LEVEL]
  131.    Screen Copy Logic To Physic : Rem This seems to be a lot quicker than just using autoback 0
  132.    PLACESPEEDUP
  133.    A=Rnd(10)
  134.    If A<5 Then PLACEENERGYUP
  135.    Bob 5,10,150,2
  136.    Amal 5,B$
  137.    Screen Show 
  138.    View 
  139.    Amal On 
  140.    Timer=0
  141. End Proc
  142. Procedure PLACESPEEDUP
  143.    Rem Picks a random spot for a speedup icon 
  144.    X=Rnd(300)+10 : Y=((Rnd(3)+1)*45)-16
  145.    C$=" A 0,(15,4)(16,4)(17,4) "
  146.    Bob 6,X,Y,15
  147.    Channel 6 To Bob 6
  148.    Amal 6,C$
  149.    Amal On 
  150. End Proc
  151. Procedure PLACEENERGYUP
  152.    Rem Picks a random spot for an energy up icon
  153.    X=Rnd(300)+10 : Y=((Rnd(3)+1)*45)-16
  154.    D$=" A 0,(20,4)(21,4)(17,4) "
  155.    Bob 7,X,Y,20
  156.    Channel 7 To Bob 7
  157.    Amal 7,D$
  158.    Amal On 
  159. End Proc
  160. Procedure ENPRO
  161.    Rem Procedure to end program and to display level reached
  162.    Amal Off 
  163.    Fade 6
  164.    Wait 75
  165.    Bob Off 
  166.    Screen 1
  167.    Cls 
  168.    For I=0 To 30
  169.       Locate 0,I : Print "Game Over"
  170.       Locate 31,I : Print "Game Over"
  171.    Next I
  172.    Locate 11,9 : Print "Level Reached :";LEVEL
  173.    Locate 12,11 : Print "Total Time:";TIME
  174.    Locate 14,17 : Print "Press Fire"
  175.    If LEVEL>HILEVEL
  176.       HILEVEL=LEVEL
  177.       HITIME=TIME
  178.    End If 
  179.    Wait Vbl 
  180.    Screen To Front 1
  181.    View 
  182.    Repeat 
  183.    Until Fire(1)
  184.    EX=0
  185. End Proc
  186. Procedure MAIN
  187.    Rem This is the main control loop while the game is running  
  188.    Do 
  189.       If EX Then Pop Proc
  190.       Screen Swap : Wait Vbl 
  191.       Bob Clear 
  192.       Locate 0,25 : Print "Energy Level :";ENERGY;"  "
  193.       Locate 21,25 : Print "Speedup Level :";Amreg(4);" "
  194.       If(Amreg(0)>303) and(PLATFORM=0 or PLATFORM=2)
  195.          PLATFORM=PLATFORM+1
  196.          Amreg(1)=1
  197.       End If 
  198.       If(Amreg(0)<15) and PLATFORM=1
  199.          PLATFORM=PLATFORM+1
  200.          Amreg(2)=1
  201.       End If 
  202.       If PLATFORM=3 and Amreg(0)<15
  203.          Bob Off 
  204.          LEVELDRAW
  205.       End If 
  206.       A=Bob Col(5,0 To 4)
  207.       If A
  208.          ENERGY=ENERGY-1
  209.          Z=Rnd(1)
  210.          If Z=1
  211.             Sam Play 8,1,6000
  212.          Else Sam Play 8,2,6000
  213.          End If 
  214.          Locate 0,25 : Print "Energy Level :";ENERGY;"  "
  215.       End If 
  216.       A=Bob Col(5,6 To 6)
  217.       If A
  218.          Bob Off 6
  219.          Amal Off 6
  220.          Amreg(4)=Amreg(4)+20
  221.       End If 
  222.       A=Bob Col(5,7 To 7)
  223.       If A
  224.          Bob Off 7
  225.          Amal Off 7
  226.          ENERGY=ENERGY+10
  227.       End If 
  228.       If Amreg(4)>0 Then Amreg(5)=1
  229.       If Amreg(4)<=0 Then Amreg(5)=0
  230.       If ENERGY=0
  231.          B$="A 1,(5,5)(6,5)(7,5)(8,5)(9,5) ; A 4,(18,5)(9,7)(19,5)(9,7) ; For R0=1 To 122 ; Next R0 ; Let RG=1 ;"
  232.          Amal 5,B$
  233.          Amal On 
  234.       End If 
  235.       If Amreg(6)=1 Then Pop Proc
  236.       Scroll 1
  237.       Screen Copy ,0,215,2,225 To Logic,318,215
  238.       Screen Copy ,0,215,2,225 To ,318,215
  239.       Bob Draw 
  240.       If LEVEL=10 Then Pop Proc
  241.    Loop 
  242. End Proc
  243. Procedure MAINAMA
  244.    Rem Main control amal string for character. This is packed to the limit  
  245.    B$=" AUtotest(If RF=1&R0&16 Jump Xast ; Let R3=0 ; eXit ;"
  246.    B$=B$+" Xast:  Let R3=1 ;Let RE=RE-1; eXit ;)"
  247.    B$=B$+" Let R1=0 ;"
  248.    B$=B$+" Begin:  Let R0=J1 ; "
  249.    B$=B$+" If RB=1 Jump Climber ; "
  250.    B$=B$+" If RC=1 Jump Eclimber ; "
  251.    B$=B$+" If R0&4 Jump Left  ; "
  252.    B$=B$+" If R0&8 Jump Right ; "
  253.    B$=B$+" Let R3=0 ; Jump Begin ;"
  254.    B$=B$+" Climber: Let RB=0 ; A 0,(12,3)(13,3)(14,3) ; M 0,-45,45 ; Jump Turner ;"
  255.    B$=B$+" Eclimber: Let RC=0 ; A 0,(12,3)(13,3)(14,3) ; M 0,-45,45 ; L X=12 ; Jump Uturner ;"
  256.    B$=B$+" Left: If R1<>1 Jump Turner ; Wnext: Let R1=1 ; A 0,($8002,3)($8003,3)($8004,3) ; Dcheck: If R3=1 Jump Nfast ;Let R4=2 ; Mcont: Move -2,0,R4 ; Let R0=J1 ; Let RA=X ; If X<10 Jump Fixer ; If R0&4 Jump Dcheck ;"
  257.    B$=B$+" A 0,($8005,1) ; Jump Begin ; Fixer: Let X=10 ; A 0,($8005,1) ; Jump Begin ; Nfast: Let R4=1 ; Jump Mcont ;"
  258.    B$=B$+" Turner: A 1,(5,3)(6,3)(7,3)(8,3)(9,3)($8009,3)($8008,3)($8007,3)($8006,3)($8005,3) ; For R2=0 To 25 ; Next R2 ; Jump Wnext ;"
  259.    B$=B$+" Right: If R1=1 Jump Uturner ; Vnext: Let R1=0 ; A 0,(2,3)(3,3)(4,3) ; Ycheck : If R3=1 Jump Ofast ; Let R4=2; Pcont: Move 2,0,R4 ; Let R0=J1; Let RA=X ; If X>310 Jump Gfixer ; If R0&8 Jump Ycheck ; "
  260.    B$=B$+" A 0,(5,1) ; Jump Begin ; Gfixer: Let X=310 ; A 0,(5,1) ; Jump Begin ;Ofast: Let R4=1 ; Jump Pcont ;"
  261.    B$=B$+" Uturner: A 1,($8005,3)($8006,3)($8007,3)($8008,3)($8009,3)(9,3)(8,3)(7,3)(6,3) ; For R2=0 To 25 ; Next R2; Jump Vnext ;"
  262. End Proc
  263. Do 
  264.    Rem this is the main loop
  265.    Update Off 
  266.    Screen 2
  267.    Pen 1 : Paper 0
  268.    Flash Off : Curs Off 
  269.    Cls 0
  270.    Locate 11,11 : Print "Lift Runner V1.00"
  271.    Locate 11,13 : Print " Best Level/Time"
  272.    Locate 15,15 : Print HILEVEL;" /";HITIME
  273.    Locate 13,18 : Print "Programmed By" : Locate 11,19 : Print " Nigel Fredericks"
  274.    Locate 10,21 : Print "Press Fire To Start"
  275.    Locate 8,22 : Print "Or Left Mouse To Exit..."
  276.    Locate 6,27 : Print "Written in AMOS The Creator"
  277.    Locate 13,29 : Print "25 July 1991"
  278.    F$=" Begin: A 0,(2,3)(3,3)(4,3) ; M 300,0,300 ;"
  279.    F$=F$+" A 1,(5,3)(6,3)(7,3)(8,3)(9,3)($8009,3)($8008,3)($8007,3)($8006,3)($8005,3) ; For R2=0 To 25 ; Next R2 ; "
  280.    F$=F$+" A 0,($8002,3)($8003,3)($8004,3) ; M -300,0,300 ;"
  281.    F$=F$+" A 1,($8005,3)($8006,3)($8007,3)($8008,3)($8009,3)(9,3)(8,3)(7,3)(6,3) ; For R2=0 To 25 ; Next R2; Jump Begin ;"
  282.    Get Sprite Palette 
  283.    Bob 8,10,40,2
  284.    Channel 8 To Bob 8
  285.    Amal 8,F$
  286.    Amal On 8
  287.    Wait Vbl 
  288.    Screen Copy Logic To Physic
  289.    Screen To Front 2
  290.    View 
  291.    Repeat 
  292.       Screen Swap : Wait Vbl 
  293.       Bob Clear 
  294.       If Mouse Click
  295.          Music Off 
  296.          End 
  297.       End If 
  298.       Bob Draw 
  299.    Until Fire(1)
  300.    Amal Off 8 : Bob Off 8
  301.    Channel 5 To Bob 5
  302.    PLATFORM=0 : LEVEL=-1 : ENERGY=40 : Amreg(4)=20 : TIME=0 : Amreg(6)=0
  303.    MAINAMA
  304.    LEVELDRAW
  305.    MAIN
  306.    ENPRO
  307. Loop